Skip to content

8386473: DESKeySpec and DESedeKeySpec may throw InvalidKeyException instead of ArrayIndexOutOfBoundsException for Integer.MIN_VALUE offset - #31494

Closed
smemery wants to merge 3 commits into
openjdk:masterfrom
smemery:JDK-8386473
Closed

smemery wants to merge 3 commits into
openjdk:masterfrom
smemery:JDK-8386473

Conversation

@smemery

@smemery smemery commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This fix includes throwing the correct exception when an offset for the key length check would cause an integer overflow therefore throwing the wrong exception.



Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8386473: DESKeySpec and DESedeKeySpec may throw InvalidKeyException instead of ArrayIndexOutOfBoundsException for Integer.MIN_VALUE offset (Bug - P2)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31494/head:pull/31494
$ git checkout pull/31494

Update a local copy of the PR:
$ git checkout pull/31494
$ git pull https://git.openjdk.org/jdk.git pull/31494/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31494

View PR using the GUI difftool:
$ git pr show -t 31494

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31494.diff

Using Webrev

Link to Webrev Comment

smemery added 2 commits June 11, 2026 18:31
…nstead of ArrayIndexOutOfBoundsException for Integer.MIN_VALUE offset
@bridgekeeper

bridgekeeper Bot commented Jun 12, 2026

Copy link
Copy Markdown

👋 Welcome back semery! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jun 12, 2026

Copy link
Copy Markdown

@smemery This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8386473: DESKeySpec and DESedeKeySpec may throw InvalidKeyException instead of ArrayIndexOutOfBoundsException for Integer.MIN_VALUE offset

Reviewed-by: mullan, syan

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 213 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@seanjmullan, @sendaoYan) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk

openjdk Bot commented Jun 12, 2026

Copy link
Copy Markdown

@smemery The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Jun 12, 2026
@mlbridge

mlbridge Bot commented Jun 12, 2026

Copy link
Copy Markdown

Webrevs

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Jun 12, 2026
@smemery

smemery commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk openjdk Bot added the sponsor Pull request is ready to be sponsored label Jun 12, 2026
@openjdk

openjdk Bot commented Jun 12, 2026

Copy link
Copy Markdown

@smemery
Your change (at version bb25897) is now ready to be sponsored by a Committer.

boolean weak = DESKeySpec.isWeak(strongKey, Integer.MIN_VALUE);
throw new Exception("expected ArrayIndexOutOfBoundsException");
} catch (ArrayIndexOutOfBoundsException aiobe) {}
try{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several try{ missed a whitespace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest delta.

* @summary DESKeySpec.isWeak should throw aiobe exception if the offset is
* negative.
* @bug 8364121 8386473
* @summary Test DES[ede]KeySpec for negative and integer overflow offsets
*/
import java.security.InvalidKeyException;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'import InvalidKeyException' seems useless.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, removed.

@openjdk openjdk Bot removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated labels Jun 13, 2026
@smemery

smemery commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk

openjdk Bot commented Jun 14, 2026

Copy link
Copy Markdown

@smemery This pull request has not yet been marked as ready for integration.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Jun 18, 2026
@smemery

smemery commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk openjdk Bot added the sponsor Pull request is ready to be sponsored label Jun 18, 2026
@openjdk

openjdk Bot commented Jun 18, 2026

Copy link
Copy Markdown

@smemery
Your change (at version 846a692) is now ready to be sponsored by a Committer.

@seanjmullan

Copy link
Copy Markdown
Member

/sponsor

@openjdk

openjdk Bot commented Jun 18, 2026

Copy link
Copy Markdown

Going to push as commit 1ad2db7.
Since your change was applied there have been 213 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Jun 18, 2026
@openjdk openjdk Bot closed this Jun 18, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Jun 18, 2026
@openjdk

openjdk Bot commented Jun 18, 2026

Copy link
Copy Markdown

@seanjmullan @smemery Pushed as commit 1ad2db7.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@smemery

smemery commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

/backport :jdk27

@openjdk

openjdk Bot commented Jun 19, 2026

Copy link
Copy Markdown

@smemery the backport was successfully created on the branch backport-smemery-1ad2db7a-jdk27 in my personal fork of openjdk/jdk. To create a pull request with this backport targeting openjdk/jdk:jdk27, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 1ad2db7a from the openjdk/jdk repository.

The commit being backported was authored by Shawn Emery on 18 Jun 2026 and was reviewed by Sean Mullan and SendaoYan.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk:

$ git fetch https://github.com/openjdk-bots/jdk.git backport-smemery-1ad2db7a-jdk27:backport-smemery-1ad2db7a-jdk27
$ git checkout backport-smemery-1ad2db7a-jdk27
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk.git backport-smemery-1ad2db7a-jdk27

⚠️ @smemery You are not yet a collaborator in my fork openjdk-bots/jdk. An invite will be sent out and you need to accept it before you can proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated security [email protected]

Development

Successfully merging this pull request may close these issues.

3 participants